' GW-BASIC program found at Stephen Smith's Blog entry "Playing with FreeDOS and GW-Basic"
' (https://smist08.wordpress.com/2022/10/06/playing-with-freedos-and-gw-basic/)
' BASIC Anywhere Machine version by Charlie Veniot
' Left as is except for commented out code (line 60 partially; line 255 completely)
10 REM Program to Draw a Koch Snowflake
20 DIM DIST(10)
30 DIM LEVEL(10)
40 ST = 1
50 SCREEN 9
55 CLS
60 PRINT "Koch Snowflake" ' (hit enter to continue)"
70 SX = 40
80 SY = 100
90 SA = 0
100 ST = 1
110 DIST(1) = 270
120 LEVEL(1) = 4
130 PI = 3.14159
140 X = SX
150 Y = SY
160 A = SA
170 A = A + 60
180 ST = 1
190 GOSUB 300
200 A = A - 120
210 ST = 1
220 GOSUB 300
230 A = A - 120
240 ST = 1
250 GOSUB 300
' 255 INPUT T$
260 END
300 REM Snowflake Side Subroutine
310 BR = 0
320 ST = ST + 1
330 IF LEVEL(ST - 1) = 1 THEN BR = 1
340 IF BR = 1 THEN ST = ST - 1
350 IF BR = 1 THEN GOSUB 1000
360 IF BR = 1 THEN RETURN
370 LEVEL(ST) = LEVEL(ST - 1) - 1
380 DIST(ST) = DIST(ST-1) / 3
390 GOSUB 300
400 A = A + 60
410 GOSUB 300
420 A = A - 120
430 GOSUB 300
440 A = A + 60
450 GOSUB 300
460 ST = ST - 1
470 RETURN
1000 REM Tutle Move Routine
1010 OX = X
1020 OY = Y
1030 X = X + DIST(ST) * COS(A*PI/180)
1040 Y = Y + DIST(ST) * SIN(A*PI/180)
1050 LINE (OX,OY)-(X,Y)
1060 RETURN